#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+50;
int t,n,q,x;
ll a[N],p[N];
int main(void){
    scanf("%d",&t);
    while(t--){
        scanf("%d",&n);
        memset(a,0,sizeof(a));
        memset(p,0,sizeof(p));
        for(int i=1;i<=n;i++){
            scanf("%lld",&a[i]);
            p[i]=p[i-1]+a[i];
        }
        scanf("%d",&q);
        vector<ll> res;
        while(q--){
            scanf("%d",&x);
            res.push_back(p[x]);
        }
        int l=res.size();
        for(int i=0;i<l;i++){
            if(i!=0){
                printf(" ");
            }
            printf("%lld",res[i]);
        }
        printf("\n");
    }
    return 0;
}